home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / zbpc_460.zip / UTILITY.EXE / BCD2BIN.INS < prev    next >
Text File  |  1991-06-08  |  913b  |  27 lines

  1. :'optional dim statement to reduce string size requirements
  2. DIM 6R1$,64R2$,1R3$
  3.  
  4.  
  5. LONGFN BCD2BIN# (R$)    :'Pass BCD varible in a STRING...
  6.   :'BCD data format     :'...and it will be converted to binary floating point
  7.   :'to BINARY format    :'IE. Pass in BCD variable in a string 'READ#3,x$;8'
  8.                         :'                       ...instead of 'READ#3,x#  '
  9.   R2$=""                :'   and then do 'x#=FN BCD2BIN#(x$)
  10.   R1$=LEFT$(R$,1):R1%=ASC(R1$)
  11.   IF R1%>127 THEN R2$="-"
  12.   R1%=R1% AND 127
  13.   FOR R2%= 2 TO LEN(R$)
  14.      R1$=MID$(R$,R2%,1):R1$=RIGHT$(HEX$(ASC(R1$)),2)
  15.      LONGIF R2%=2
  16.           :R3$=LEFT$(R1$,1):R1$=RIGHT$(R1$,1)
  17.           :R2$=R2$+R3$+"."+R1$
  18.      XELSE :R2$=R2$+R1$
  19.      ENDIF
  20.   NEXT
  21.   R2$=R2$+"E":IF R1%>64 THEN R1%=-(128-R1%)
  22.             :R1$=STR$(R1%)
  23.             :IFASC(R1$)=32 THEN MID$(R1$,1,1)="+"
  24.             R2$=R2$+R1$
  25.   ENDFN=VAL(R2$)
  26.  
  27.